<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 下拉菜单
   van-dropdown-menu
       van-dropdown-item  
             v-model:选中项的值
             options:下拉选项[{text:文本,value:选中后的值}]
             slot="default/title"
-->
      <h3>{{ txt }}</h3>
      <van-dropdown-menu>
        <van-dropdown-item v-model="txt" :options="options">
          <template #title>
            <div>面试宝典{{ getCity }}</div>
          </template>
        </van-dropdown-item>
      </van-dropdown-menu>
    </div>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/vant@2.11/lib/index.css"
    />

    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@2.11/lib/vant.min.js"></script>
    <script>
      new Vue({
        el: '#app',
        data: {
          txt: 'gx',
          options: [
            { text: '广东省', value: 'gd' },
            { text: '广西省', value: 'gx' },
            { text: '湖北省', value: 'hb' }
          ]
        },
        computed: {
          getCity () {
            const _index = this.options.findIndex(item => {
              return item.value === this.txt
            })
            if (_index === -1) {
              return ''
              
            } else {
              return this.options[_index].text
            }
          }
        }
      })
    </script>
  </body>
</html>
